import request from '../utils/request';

// 客户信息管理相关API
export const customerApi = {
  // 分页查询客户列表
  getCustomerList: (params) => {
    return request.get('/api/customers/page', { params });
  },

  // 根据ID查询客户详情
  getCustomerDetail: (id) => {
    return request.get(`/api/customers/${id}`);
  },

  // 根据编码查询客户
  getCustomerByCode: (code) => {
    return request.get(`/api/customers/code/${code}`);
  },

  // 新增客户
  createCustomer: (data) => {
    return request.post('/api/customers', data);
  },

  // 更新客户信息
  updateCustomer: (id, data) => {
    return request.put(`/api/customers/${id}`, data);
  },

  // 删除客户
  deleteCustomer: (id) => {
    return request.delete(`/api/customers/${id}`);
  },

  // 根据状态查询客户列表
  getCustomersByStatus: (status) => {
    return request.get(`/api/customers/status/${status}`);
  },

  // 查询所有客户列表
  getAllCustomers: () => {
    return request.get('/api/customers/all');
  },

  // 搜索客户（按名称或编码）
  searchCustomers: (keyword) => {
    return request.get('/api/customers/search', { params: { keyword } });
  }
};
